<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
 <%@ include file="/common/query.jsp"%>
<%@ include file="/common/det.jsp"%>
<script type="text/javascript" src="${base}/js/plugin/jquery-form/jquery.form.min.js"></script>
<script>
    	var url='/member/manager?';
		var fenpeiView = getQueryStringByDecode("fenpeiView");
        $(function(){
            if(fenpeiView!=null && fenpeiView=="true"){
                initFenpeiView();
			}else{
                initIndex();   
			}
             
        });
        function initIndex(){

            var columns = [
                {field:'id',title:'id',hidden:true},
                {field:'username',title:'姓名'},
                {field:'sex',title:'性别',search:{type:"single"},
                    input:{type:'radio',value : [{text:"未知",value:0,isDefault:true},{text:'男',value:1},{text:'女',value : 2}]}
                },
                {field:'birthday',title:'生日',type:"date"},
                {field:'isSchool',title:'学校',search:{type:"single"},
                    input:{type:'radio',value : [{text:"无",value:0,isDefault:true},{text:'有',value:1}]}
                },
                {field:'parent',title:'监护人',search:{type:"single"}},
                {field:'handset',title:'电话',search:{type:"single"}},
                {field:'address',title:'住址',search:{type:"single"}},
                {field:'collectTime',title:'收集时间',type:"date"},
                {field:'remark',title:'备注'},
                {field:'memberGradeId',title:'客户等级',hidden:true},
                {field:'memberGradeName',title:'客户等级',
                    dialog:{
                        url:"${base}/member/grade?selectView=true",
                        width:300,
                        height:300,
                        select:function(iframe){
                            var row = iframe.getGridChecked()[0];
                            $('#crud-memberGradeId').val(row.id);
                            $('#crud-memberGradeName').val(row.name);
                        }
                    }
				},
                {field:'keyGrade',title:'重要等级'},
                {field:'activityLocation',title:'活动位置'},
                {field:'marketingUserId',title:'市场顾问',hidden:true},
                {field:'marketingUserName',title:'市场顾问',
                    dialog:{
                        url:"${base}/system/user?fenpeiView=member",
                        width:300,
                        height:300,
                        select:function(iframe){
                            var row = iframe.getGridChecked()[0];
                            $('#crud-marketingUserId').val(row.id);
                            $('#crud-marketingUserName').val(row.name);
                        }
                    }
                },
                {field:'salesUserId',title:'销售顾问',hidden:true},
                {field:'salesUserName',title:'销售顾问',
                    dialog:{
                        url:"${base}/system/user?fenpeiView=member",
                        width:300,
                        height:300,
                        select:function(iframe){
                            var row = iframe.getGridChecked()[0];
                            $('#crud-salesUserId').val(row.id);
                            $('#crud-salesUserName').val(row.name);
                        }
                    }
                },
                {field:'headUrl',title:'头像',type:'img'},
                {field:'status',title:'状态',
                    input:{type:'radio',value : [
                        {text:"潜在客户",value:10,isDefault:true},
						{text:'意向客户',value:20},
						{text:'普通会员',value:30},
                        {text:'VIP客户',value:40}]}
                }

            ];
            createQuery('body',columns,{pager:true,edit:true,xuhao:false,add:true,del:false,heji:false,singleSelect:true,
                toolbar:[
                    	{text : '<a class="pure-button pure-button-primary" href="javascript:void(0)" onclick="fileClick()">导入市场资料</a>'
                            ,handler : function(){

						}},
                    	{text : '<a  class="pure-button pure-button-primary" >批量分配顾问</a>',handler : function(){
                            layer.open({
                                type: 2,
                                title: "批量分配顾问",
                                shadeClose: true,
                                shade: 0.8,
                                area: ["90%","90%"],
                                content: "${base}/member/批量分配顾问",
                                btn:['关闭'],
                                yes: function (index, layero) {
                                    layer.close(index);
                                },
                            });
						}},
						{text : '<a  class="pure-button pure-button-primary" >详细信息</a>',handler : function(){
						    	var row = getGridChecked()[0];
								window.top.tabAdd(""+row.username+"详细信息","${base}/member/会员详细信息?id="+row.id)
						}}
                ],
                loadSuccess:function () {
                    $('.datagrid-toolbar').append('<div style="margin-top: 10px;margin-left: 1px;">' +
						'<a  class="pure-button" >全部客户</a>' +'<a  class="pure-button" >潜在客户</a>'+
                        '<a  class="pure-button" >意向客户</a>' +'<a  class="pure-button" >普通会员</a>'+
                        '<a  class="pure-button" >VIP客户</a>' +
						'</div>')
                }
			},url);

        }
        function initFenpeiView() {
            var columns = [
                {field:'id',title:'id',hidden:true},
                {field:'username',title:'姓名',search:{type:"single"}},
                {field:'sex',title:'性别',search:{type:"single"},
                    input:{type:'radio',value : [{text:"未知",value:0,isDefault:true},{text:'男',value:1},{text:'女',value : 2}]}
                },
                {field:'birthday',title:'生日',type:"date"},
            ];
            url += "search_EQ_salesUserId=0&";
            createQuery('body',columns,{pager:true,edit:false,editBtn:false,xuhao:false,add:false,del:false,heji:false,singleSelect:false},url);
        }

        function sumbitAjax(){
            var form = $("#file_form");
            var options  = {
                url:'/fileExcel/import',
                dataType:'json',
                success:function(data)
                {    //成功执行的方法
                    $('#file_input').val("");
                    alert("执行成功");
                }
            };
            form.ajaxSubmit(options);
        }
    function fileClick(){
        $('#file_input').click();
    }
</script>
</head>
<body>
	  <div id="body"></div>
      <form id="file_form" action="/fileExcel/import" enctype="multipart/form-data"
            method="post">
          <input type="file" name="file" id="file_input" onchange="sumbitAjax()" style="display:none"/>
          <input type="submit" value="文件上传" id='upFile-btn'style="display:none">
      </form>
</body>
</html>